package com.srwl.mytx.domain;

import android.os.Parcel;
import android.os.Parcelable;

import com.srwl.mytx.domain.User;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Orders implements Parcelable {
    private String id;

    private String uId;

    private String aId;//广告位id

    private String oId;//订单id

    private String tId;//主题id

    private String expressId;//物流单号

    private String expressName;//物流名称

    private String title;//冗余保存的商品标题

    private String sellerId;//卖家id

    private Double deposit;

    private Double amount;

    private Integer offerCount;

    private String contact;

    private String phone;

    private Double refund;//退款金额

    private Integer refundCount;

    private List<String> reasons;//退款原因

    private String address;

    private Date expiryDate;

    private Integer type;

    private Integer status;

    private Integer sendStatus;

    private Integer refundStatus;//退款状态（退款的类型）

    private Date updated;

    private Date created;

    private User user;

    private Advertisement advertisement;

    private Topic topic;


    public Orders(String id, String uId, String aId, String tId, String title, String sellerId, Double deposit, Double amount, String contact, String phone, Double refund, Integer refundCount, List reasons, String address, Integer offerCount, Date expiryDate, Integer type, Integer status, Integer sendStatus, Integer refundStatus, Date updated, Date created) {
        this.id = id;
        this.uId = uId;
        this.aId = aId;
        this.tId = tId;
        this.title = title;
        this.sellerId = sellerId;
        this.deposit = deposit;
        this.amount = amount;
        this.contact = contact;
        this.phone = phone;
        this.refund = refund;
        this.refundCount = refundCount;
        this.reasons = reasons;
        this.address = address;
        this.offerCount = offerCount;
        this.expiryDate = expiryDate;
        this.type = type;
        this.status = status;
        this.sendStatus = sendStatus;
        this.refundStatus = refundStatus;
        this.updated = updated;
        this.created = created;
    }

    public Orders() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId == null ? null : uId.trim();
    }

    public String getaId() {
        return aId;
    }

    public void setaId(String aId) {
        this.aId = aId == null ? null : aId.trim();
    }

    public String getoId() {
        return oId;
    }

    public void setoId(String oId) {
        this.oId = oId;
    }


    public String getExpressId() {
        return expressId;
    }

    public void setExpressId(String expressId) {
        this.expressId = expressId;
    }

    public String getExpressName() {
        return expressName;
    }

    public void setExpressName(String expressName) {
        this.expressName = expressName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String gettId() {
        return tId;
    }

    public void settId(String tId) {
        this.tId = tId == null ? null : tId.trim();
    }

    public Double getDeposit() {
        return deposit;
    }

    public void setDeposit(Double deposit) {
        this.deposit = deposit;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Integer getOfferCount() {
        return offerCount;
    }

    public void setOfferCount(Integer offerCount) {
        this.offerCount = offerCount;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getSendStatus() {
        return sendStatus;
    }

    public void setSendStatus(Integer sendStatus) {
        this.sendStatus = sendStatus;
    }

    public Integer getRefundStatus() {
        return refundStatus;
    }

    public void setRefundStatus(Integer refundStatus) {
        this.refundStatus = refundStatus;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getSellerId() {
        return sellerId;
    }

    public void setSellerId(String sellerId) {
        this.sellerId = sellerId;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Double getRefund() {
        return refund;
    }

    public void setRefund(Double refund) {
        this.refund = refund;
    }

    public Integer getRefundCount() {
        return refundCount;
    }

    public void setRefundCount(Integer refundCount) {
        this.refundCount = refundCount;
    }

    public List<String> getReasons() {
        if (reasons == null) {
            reasons = new ArrayList<>();
        }
        return reasons;
    }

    public List<String> addReason(String reason) {
        if (reasons == null) {
            reasons = new ArrayList<>();
        }
        reasons.add(reason);
        return reasons;
    }
    public void setReasons(List<String> reasons) {
        this.reasons = reasons;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Date getExpiryDate() {
        return expiryDate;
    }

    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }

    public Advertisement getAdvertisement() {
        return advertisement;
    }

    public void setAdvertisement(Advertisement advertisement) {
        this.advertisement = advertisement;
    }

    public Topic getTopic() {
        return topic;
    }

    public void setTopic(Topic topic) {
        this.topic = topic;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.uId);
        dest.writeString(this.aId);
        dest.writeString(this.oId);
        dest.writeString(this.tId);
        dest.writeString(this.expressId);
        dest.writeString(this.expressName);
        dest.writeString(this.title);
        dest.writeString(this.sellerId);
        dest.writeValue(this.deposit);
        dest.writeValue(this.amount);
        dest.writeValue(this.offerCount);
        dest.writeString(this.contact);
        dest.writeString(this.phone);
        dest.writeValue(this.refund);
        dest.writeValue(this.refundCount);
        dest.writeStringList(this.reasons);
        dest.writeString(this.address);
        dest.writeLong(this.expiryDate != null ? this.expiryDate.getTime() : -1);
        dest.writeValue(this.type);
        dest.writeValue(this.status);
        dest.writeValue(this.sendStatus);
        dest.writeValue(this.refundStatus);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeParcelable(this.user, flags);
        dest.writeParcelable(this.advertisement, flags);
        dest.writeParcelable(this.topic, flags);
    }

    protected Orders(Parcel in) {
        this.id = in.readString();
        this.uId = in.readString();
        this.aId = in.readString();
        this.oId = in.readString();
        this.tId = in.readString();
        this.expressId = in.readString();
        this.expressName = in.readString();
        this.title = in.readString();
        this.sellerId = in.readString();
        this.deposit = (Double) in.readValue(Double.class.getClassLoader());
        this.amount = (Double) in.readValue(Double.class.getClassLoader());
        this.offerCount = (Integer) in.readValue(Integer.class.getClassLoader());
        this.contact = in.readString();
        this.phone = in.readString();
        this.refund = (Double) in.readValue(Double.class.getClassLoader());
        this.refundCount = (Integer) in.readValue(Integer.class.getClassLoader());
        this.reasons = in.createStringArrayList();
        this.address = in.readString();
        long tmpExpiryDate = in.readLong();
        this.expiryDate = tmpExpiryDate == -1 ? null : new Date(tmpExpiryDate);
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.sendStatus = (Integer) in.readValue(Integer.class.getClassLoader());
        this.refundStatus = (Integer) in.readValue(Integer.class.getClassLoader());
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        this.user = in.readParcelable(User.class.getClassLoader());
        this.advertisement = in.readParcelable(Advertisement.class.getClassLoader());
        this.topic = in.readParcelable(Topic.class.getClassLoader());
    }

    public static final Creator<Orders> CREATOR = new Creator<Orders>() {
        @Override
        public Orders createFromParcel(Parcel source) {
            return new Orders(source);
        }

        @Override
        public Orders[] newArray(int size) {
            return new Orders[size];
        }
    };
}